package com.richest.api.controller.cn.client.extension;

import org.eclipse.jdt.internal.compiler.ast.TrueLiteral;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.richest.api.service.IUserExtensionService;
import com.richest.util.CallResults;
import com.richest.util.StringUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * 
 * @author zhaohongchao 2019年3月17日 下午1:53:18
 * @email 70375739@qq.com
 */
@RestController
@RequestMapping("extensionController")
@Api(value = "促销活动接口")
@EnableAutoConfiguration
public class ApiUserExtensionController {
	@Autowired
	private IUserExtensionService userExtensionService;

	/**
	 * 领取优惠卷/赠送金
	 */
	@RequestMapping(value = "receiveExtension", produces = "application/json;charset=UTF-8")
	@ApiOperation(notes = "领取优惠卷/赠送金", value = "领取优惠卷/赠送金", httpMethod = "GET")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "userId", value = "用户ID", required = true, paramType = "query", dataType = "Long"),
			@ApiImplicitParam(name = "extensionDetailId", value = "优惠卷ID", required = true, paramType = "query", dataType = "Long") })
	public CallResults getEatOrderBySerialNumber(@RequestParam Long userId, @RequestParam Long extensionDetailId) {
		return userExtensionService.receiveExtension(userId, extensionDetailId);
	}

	/**
	 * 获取活动/优惠卷列表
	 */
	@RequestMapping(value = "getExtensionList", produces = "application/json;charset=UTF-8")
	@ApiOperation(notes = "获取活动/优惠卷列表", value = "获取活动/优惠卷列表", httpMethod = "GET")

	@ApiImplicitParams({
			@ApiImplicitParam(name = "userId", value = "用户ID", required = true, paramType = "query", dataType = "Long"),
			@ApiImplicitParam(name = "type", value = "类型，赠送金=3，其他=0", required = true, paramType = "query", dataType = "Integer") })
	public CallResults getExtensionList(@RequestParam Long userId, @RequestParam Integer type) {
		return userExtensionService.getExtensionList(userId, type);
	}

	/**
	 * 获取已经拥有的优惠卷列表
	 */
	@RequestMapping(value = "getOwnExtensionList", produces = "application/json;charset=UTF-8")
	@ApiOperation(notes = "获取已经拥有的优惠卷列表", value = "获取已经拥有的优惠卷列表", httpMethod = "GET")
	@ApiImplicitParam(name = "userId", value = "用户ID", required = true, paramType = "query", dataType = "Long")
	public CallResults getOwnExtensionList(@RequestParam Long userId) {
		return userExtensionService.getOwnExtensionList(userId);
	}
}
